#ifndef LOADINGSTATE_H
#define LOADINGSTATE_H

#include "State.h"
#include <string>
#include <boost/thread.hpp>

class GeometryGenerator;

class LoadingState : public State
{
public:
    LoadingState(Overseer *o, std::string f);
    void initialise();
    void exit();
    void pause();
    void resume();
    void update(double timeSinceLastFrame);
    void loadMap();
    std::string getStatus();
    float getProgress();
    std::string getError();
protected:
    bool keyPressed(const OIS::KeyEvent &evt);
    bool keyReleased(const OIS::KeyEvent &evt);
    bool mouseMoved(const OIS::MouseEvent &evt);
    bool mousePressed(const OIS::MouseEvent &evt, OIS::MouseButtonID id);
    bool mouseReleased(const OIS::MouseEvent &evt, OIS::MouseButtonID id);
private:
    void setStatus(float p, std::string s);
    void throwError(std::string e);
    boost::thread loaderThread;
    boost::mutex errorMutex,statusMutex;
    std::string statusMessage, errorMessage;
    GeometryGenerator *generator;
    std::string filename;
    float progress;
};

#endif
